package com.chushouya.controller.partner;

import com.chushouya.common.annotations.SignValidate;
import com.chushouya.common.constant.ServiceType;
import com.general.framework.core.lang.Beans;
import com.general.framework.core.schema.Response;
import com.chushouya.product.dto.api.brand.BrandApiQuery;
import com.chushouya.product.dto.api.brand.BrandListApiDTO;
import com.chushouya.product.dto.partner.brand.BrandPartnerApiQuery;
import com.chushouya.product.service.api.BrandApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = ServiceType.OPENAPI + "品牌接口")
@RestController
@RequestMapping( ServiceType.OPENAPI + "/brand")
@Slf4j
public class BrandPartnerController {

    @Resource
    private BrandApiService brandApiService;

    @ApiOperation("热门品牌列表")
    @GetMapping("/list")
    @SignValidate
    public Response<List<BrandListApiDTO>> brandList(BrandPartnerApiQuery query) {
        BrandApiQuery brandApiQuery = Beans.copy(query, BrandApiQuery.class);
        return Response.success(brandApiService.brandList(brandApiQuery));
    }
}
